/****************************************************************
Using PT parameter, but shut down PT option
and compare with the PT baseline model
*****************************************************************/

*by Xiaodong Fan, fanxiaodong@gmail.com

#delimit ;

cap log close;
clear all;
drop _all;
set more 1;
pause on;

log using log_MSM_health_pthpar.log, replace;

global gpicsdir "pics_health_pthpar";
global gdtadir ".";

do do_globals.do;


/***********************************************
  Moments generated in Fortran program
************************************************/

local lvptdir0 ../../../BP_MPI_pthealth/main/output;  // baseline;
local lvptdir1 ../../../BP_MPI_health_pthpar/main/output; // turn off pt option but have health;

foreach iv in 0 1 {;
    * moments of sep_ptpar;
    use lfpr_f t using `lvptdir`iv''/dta_MSM_Moments.dta, clear;
    ren lfpr_f lfpr;
    gen idpth = `iv';
    sort idpth t;
    save dta_pthpar_temp.dta, replace;

    use ihet H I lfpr t using `lvptdir`iv''/dta_MSM_Profiles.dta if ihet==0, clear;
    drop ihet;
    ren lfpr lfpr_profile;
    gen idpth = `iv';
    sort idpth t;
    merge 1:1 idpth t using dta_pthpar_temp.dta, nogenerate;
    sort idpth t;
    if (`iv' > 0) {;
        append using dta_MSM_pthpar.dta;
        sort idpth t;
    };
    save dta_MSM_pthpar.dta, replace;
};

rm dta_pthpar_temp.dta;

use dta_MSM_pthpar.dta, clear;

keep lfpr lfpr_profile H I t idpth;
sort t idpth;
reshape wide lfpr lfpr_profile H I, i(t) j(idpth);
sort t;
save dta_MSM_pthpar.dta, replace;

foreach iv in lfpr H  {;
   if ("`iv'"=="lfpr" | "`iv'"=="lfpr_profile") {;
      local lviv "Employment Rates";
      local lvpos=7;
   };
   else if ("`iv'"=="lnw") {;
      local lviv "Log Wages";
      local lvpos=5;
   };
   else if ("`iv'"=="lnw_fe") {;
      local lviv "Log Wages (FE)";
      local lvpos=5;
   };
   else if ("`iv'"=="H") {;
      local lviv "Human Capital";
      local lvpos=6;
   };
   else if ("`iv'"=="I") {;
      local lviv "Investment";
      local lvpos=2;
   };
   else {;
      local lviv "`iv'";
      local lvpos=6;
   };

   gen d`iv'1 = `iv'1 - `iv'0;

   line `iv'0 `iv'1 t if t>=${gvdata0} & t<=${gvdata10}, graphregion(color(white))
       lpattern("l" "_" "_." "-" "-." ".") xtitle("Age") ytitle("`lviv'") 
       yscale(range(${gyrange_`iv'})) ylabel(${gylabel_`iv'})
       xlabel(${gvdata0} 30(10)60 ${gvdata10},grid) xscale(range(${gvdata0} ${gvdata10}))
       legend(ring(0) pos(`lvpos') col(1) keygap(*1) symxsize(*1) symysize(*0.5) 
              order(1 "PT&Health" 2 "No PT"));
   graph export ${gpicsdir}/eps_paper_noPT_`iv'.eps, replace;
   line d`iv'1 t if t>=${gvdata0} & t<=${gvdata10}, graphregion(color(white))
       lpattern("l" "_" "_." "-" "-." ".") xtitle("Age") ytitle("Change in `lviv'") 
       xlabel(${gvdata0} 30(10)60 ${gvdata10},grid) xscale(range(${gvdata0} ${gvdata10}));
   graph export ${gpicsdir}/eps_paper_noPT_d`iv'.eps, replace;

};

cap log close;

